package array.leetcode.easy;

/**
 * @author bruin_du
 * @description 查找插入位置
 * @date 2022/8/20 22:33
 **/
public class OfferII068_SearchInsert {
    public int searchInsert(int[] nums, int target) {
        int start = 0, end = nums.length - 1;
        while (start <= end) {
            int mid = (end - start >> 1) + start;
            if (nums[mid] > target) {
                end = mid - 1;
            } else if (nums[mid] <= target) {
                start = mid + 1;
            } else return mid;
        }
        return start;
    }
}
